var utils = require("../../utils/utils");
var time = require("../../utils/time");
var ocrGml = require("../../utils/ocrGml");
var ACTION = require("../../base/action");
var common = require("./common");
var inTask = require("./inTask");
var aTreasure = new ACTION("开宝箱");
aTreasure.exec = function () {
  var contents = ["开宝箱得"];
  var ocrItem = ocrGml.captureExistOne(contents, true);
  if (ocrItem) {
    utils.clickOcrItem(ocrItem);
    sleep(utils.getRandom(2.5, 3, 1000));
    inTask.run();
    return;
  }
  var content = /领\d{1,4}金币/;
  var UIText = utils.existsTextMatches(content);
  if (UIText) {
    utils.clickUIText(UIText);
    sleep(utils.getRandom(2.5, 3, 1000));
    inTask.run();
    return;
  }
};

module.exports = aTreasure;
